using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Admin;
using System;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public class HL_Admin_Admin_Announce : Admin, IRequiresSessionState
{
	private AnnounceBll _shop_announce = null;
	protected GridView GridView1;
	protected Literal announce_js_code;
	protected ObjectDataSource ObjectDataSource1;
	protected AnnounceBll shop_anounce
	{
		get
		{
			AnnounceBll shop_announce;
			if (this._shop_announce == null)
			{
				this._shop_announce = new AnnounceBll(this.conn);
				shop_announce = this._shop_announce;
			}
			else
			{
				shop_announce = this._shop_announce;
			}
			return shop_announce;
		}
	}
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.admin.CheckAdminPower(2))
		{
			base.WriteLog("View", Language.GetAdminMsg("Log/Access", "0"), "Announce");
			base.WriteRightErrMsg();
		}
		if (base.Request["action"] == "updateJs")
		{
			bool flag = false;
			try
			{
				flag = this.shop_anounce.CreateAnnounceJs(5);
			}
			catch (Exception ex)
			{
				this.WriteErrMsg("", Language.Get("Common/Fail", ex.Message.ToString()), "");
			}
			if (flag)
			{
				this.WriteSuccessMsg("", Language.Get("Common/Success"), "Admin_Announce.aspx");
			}
			else
			{
				this.WriteErrMsg("", Language.Get("Common/Fail", "可能UploadFile文件夹没有可写权限!"), "");
			}
		}
		this.announce_js_code.Text = "<p><textarea style=\"width:100%;height:60px;\" ><!--公告JS代码开始-->\r\n<script type='text/javascript' src='/UploadFile/announce.js' charset='gb2312' ></script>\r\n<!--公告JS代码结束--></textarea></p>";
	}
	protected void GridView1_DataBound(object sender, EventArgs e)
	{
		foreach (GridViewRow gridViewRow in this.GridView1.Rows)
		{
			if (!base.admin.CheckAdminPower(2))
			{
				gridViewRow.Cells[10].Enabled = false;
			}
			string text = gridViewRow.Cells[2].Text;
			if (text == null)
			{
				goto IL_FC;
			}
			if (!(text == "0"))
			{
				if (!(text == "1"))
				{
					if (!(text == "2"))
					{
						goto IL_FC;
					}
					gridViewRow.Cells[2].Text = Language.GetAdminMsg("Announce/AnnounceType/Type2");
				}
				else
				{
					gridViewRow.Cells[2].Text = Language.GetAdminMsg("Announce/AnnounceType/Type1");
				}
			}
			else
			{
				gridViewRow.Cells[2].Text = Language.GetAdminMsg("Announce/AnnounceType/Type0");
			}
			IL_11D:
			text = gridViewRow.Cells[3].Text;
			if (text == null)
			{
				goto IL_19C;
			}
			if (!(text == "0"))
			{
				if (!(text == "1"))
				{
					goto IL_19C;
				}
				gridViewRow.Cells[3].Text = Language.GetAdminMsg("Announce/AnnounceImportant/Important1");
			}
			else
			{
				gridViewRow.Cells[3].Text = Language.GetAdminMsg("Announce/AnnounceImportant/Important0");
			}
			IL_1BD:
			Label label = (Label)gridViewRow.FindControl("Label1");
			if (label.Text.Length > 20)
			{
				label.Text = this.HtmlReplace(label.Text).Substring(0, 20) + "...";
			}
			continue;
			IL_19C:
			gridViewRow.Cells[3].Text = Language.GetAdminMsg("Announce/AnnounceImportant/Important0");
			goto IL_1BD;
			IL_FC:
			gridViewRow.Cells[2].Text = Language.GetAdminMsg("Announce/AnnounceType/Type0");
			goto IL_11D;
		}
	}
	protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#E7EDFE'");
		e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
	}
}
